module game {
    export class Processor_CHAT extends puremvc.SimpleCommand implements puremvc.ICommand {
        public constructor() {
            super();
        }
        public static NAME: string = "Processor_CHAT";
        private chatProxy: ChatProxy = null;
        /**
         * 注册消息
         */
        public register(): void {
            this.facade.registerCommand("Processor_CHAT", Processor_CHAT);
        }
        public execute(notification: puremvc.INotification): void {
            this.chatProxy = ChatProxy.getProxy();
            var Body: any = notification.getBody();
            let msgdata: Object = DataParser.WSReceiveMsg(RegDataChat, Body);
            if (Global.isEmpty(msgdata)) {
                return;
            }
            let mainCmd = msgdata["mainCmd"];
            let subCmd = msgdata["subCmd"];
            let data = msgdata["msgData"];
            if (InstructionsEnum.IS_TEST) {
                console.log("聊天服接收：", mainCmd, subCmd, msgdata)
            }
            if (Global.isEmpty(data)) {
                return;
            }
            switch (mainCmd) {
                case 1: {
                    if (subCmd == 200) {
                        console.log("聊天服务器连接成功")
                    }
                    if (subCmd == 210) {
                        console.log("聊天服务器连接失败", data["szDescribeString"])
                    }
                    if (subCmd == 306) {//异地登录
                        //主页连接断开，跳出到登陆页
                        SocketManager.closeAllSocket();
                        Global.tipShow(data["wNotifyMessage"])
                    }
                    break
                }
                case 3: {
                    if (subCmd == 214) {
                        var arr = [
                            { text: data["szString"], style: { textColor: 0xffffff, fontFamily: "Microsoft YaHei" } }
                        ]
                        EffectUtils.pushNotice(arr)
                    }
                    if (subCmd == 217) {
                        var arr = [
                            { text: "恭喜", style: { textColor: 0xffffff, fontFamily: "Microsoft YaHei" } },
                            { text: Global.cutString(data["szNickName"]), style: { textColor: 0xffce24, fontFamily: "Microsoft YaHei" } },
                            { text: '在', style: { textColor: 0xffffff, fontFamily: "Microsoft YaHei" } },
                            { text: data["szServerName"], style: { textColor: 0xffce24, fontFamily: "Microsoft YaHei" } },
                            { text: '赢了', style: { textColor: 0xffffff, fontFamily: "Microsoft YaHei" } },
                            { text: (Number(data["lScore"]) / 100).toFixed(2), style: { textColor: 0xffce24, fontFamily: "Microsoft YaHei" } },
                            { text: '元!!!', style: { textColor: 0xffffff, fontFamily: "Microsoft YaHei" } }
                        ]
                        EffectUtils.pushNotice(arr)
                    }
                    break;
                }
            }
        }
    }
}
